import java.util.LinkedList;

public class MonotonicStack {
    // 单调递减队列
    private LinkedList<Integer> list = new LinkedList<>();

    public void pop(){
        list.pollFirst();
    }

    public Integer peek(){
        return list.peekFirst();
    }

    public void push(Integer t){
        while (!list.isEmpty() && list.peekLast() < t){
            list.pollLast();
        }
        list.offerLast(t);
    }
}

// 单调递减栈
class ValueAndIndex{
    int i;
    int weight;

    public ValueAndIndex(int i, int weight){
        this.i = i;
        this.weight = weight;
    }
}
